#define _CRT_SECURE_NO_WARNINGS 1
#include <vector>
#include <algorithm>
using namespace std;
  struct ListNode {
 	int val;
	struct ListNode *next;
 	ListNode(int x) : val(x), next(nullptr) {}
  };
 
class Solution {
public:
    ListNode* sortInList(ListNode* head)
    {
        vector<int> v;
        ListNode* cur = head;
        while (cur)
        {
            v.push_back(cur->val);
            cur = cur->next;
        }
        sort(v.begin(), v.end());
        cur = head;
        int i = 0;
        while (cur)
        {
            cur->val = v[i++];
            cur = cur->next;
        }
        return head;
    }
};